package com.example.wto.myapplication;

import android.content.Context;
import android.graphics.drawable.Icon;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

/**
 * Created by wto on 4/18/2017.
 */

public class CatalogBarAdapter extends ArrayAdapter<CatalogBarBean>
{
    private Context context;
    private int resource;
    private List<CatalogBarBean> catalogBarBeanList;
    public CatalogBarAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull
            List<CatalogBarBean> objects)
    {
        super(context, resource, objects);
        this.context=context;
        this.resource=resource;
        this.catalogBarBeanList=objects;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
    {
        CatalogBarBean catalogBarBean=catalogBarBeanList.get(position);
        if(convertView==null)
        {
            convertView= LayoutInflater.from(context).inflate(resource,parent,false);
        }
        ImageView bar_img=(ImageView)convertView.findViewById(R.id.bar_iamge_view);
        TextView bar_textview=(TextView)convertView.findViewById(R.id.bar_textview);
        bar_textview.setText(catalogBarBean.getCatalogBean().getName());
        return convertView;
    }
}
